using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// User_Login - 登录账号表 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IUserLogin<T> :ModelBase<UserLogin> where T : UserLogin, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.Rowid = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return Rowid;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.Rowid=dy.Rowid;
           this.UserId=dy.UserId;
           this.Account=dy.Account;
           this.PassWord=dy.PassWord;
           this.CreateTtime=dy.CreateTtime;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 自增
        /// </summary>
        private String _Rowid = "";
      
        /// <summary>
        /// 自增
        /// </summary>
        public String Rowid
        {
            get 
            {
              return   (this._Rowid); 
            }

            set 
            {
                    _Rowid= value;  
            }
        }
       
     
         /// <summary>
        /// 用户ID
        /// </summary>
        private String _UserId = "";
      
        /// <summary>
        /// 用户ID
        /// </summary>
        public String UserId
        {
            get 
            {
              return   (this._UserId); 
            }

            set 
            {
                    _UserId= value;  
            }
        }
       
     
         /// <summary>
        /// 登录名
        /// </summary>
        private String _Account = "";
      
        /// <summary>
        /// 登录名
        /// </summary>
        public String Account
        {
            get 
            {
              return   (this._Account); 
            }

            set 
            {
                    _Account= value;  
            }
        }
       
     
         /// <summary>
        /// 密码
        /// </summary>
        private String _PassWord = "";
      
        /// <summary>
        /// 密码
        /// </summary>
        public String PassWord
        {
            get 
            {
              return   (this._PassWord); 
            }

            set 
            {
                    _PassWord= value;  
            }
        }
       
     
         /// <summary>
        /// 创建时间
        /// </summary>
        private DateTime _CreateTtime =DateTime.MinValue;
      
        /// <summary>
        /// 创建时间
        /// </summary>
        public DateTime CreateTtime
        {
            get 
            {
              return   (this._CreateTtime); 
            }

            set 
            {
                    _CreateTtime= value;  
            }
        }
       
     
       

      #endregion 定义属性 

          protected internal override void SetValue(UserLogin info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["Rowid"]!= DBNull.Value)
                  {
                  info.Rowid=row["Rowid"].ToString();
                 }
                 
                  
                  if(row["UserId"]!= DBNull.Value)
                  {
                  info.UserId=row["UserId"].ToString();
                 }
                 
                  
                  if(row["Account"]!= DBNull.Value)
                  {
                  info.Account=row["Account"].ToString();
                 }
                 
                  
                  if(row["PassWord"]!= DBNull.Value)
                  {
                  info.PassWord=row["PassWord"].ToString();
                 }
                 
                  
                  if(row["CreateTtime"]!= DBNull.Value)
                  {
                  info.CreateTtime=Convert.ToDateTime(row["CreateTtime"]);
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, UserLogin info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@Rowid", DbType.String,ParameterTool.GetObj( info._Rowid )); 
            
             
                cn.AddInParameter(comm, "@UserId", DbType.String,ParameterTool.GetObj( info._UserId )); 
            
             
                cn.AddInParameter(comm, "@Account", DbType.String,ParameterTool.GetObj( info._Account )); 
            
             
                cn.AddInParameter(comm, "@PassWord", DbType.String,ParameterTool.GetObj( info._PassWord )); 
            
             
                cn.AddInParameter(comm, "@CreateTtime", DbType.DateTime,ParameterTool.GetObj( info._CreateTtime )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 